var uuid = require('uuid');

var util = require('../libs/util');
var Project = require('../service/project');

/**
 * 发布项目
 **/
exports.create = function (req, res, next) {
    req.checkBody('title', '项目标题不能为空。').notEmpty();
    req.checkBody('content', '项目内容不能为空。').notEmpty();

    var errors = req.validationErrors();
    if (errors) {
        return res.status(400).json(errors);
    }

    var title = req.body.title;
    var content = req.body.content;

    Project.createProject(title, content, function(err, project){
        if(err) return next(err);
        res.json(project);
    })
}

/**
 * 展示项目
 **/
exports.view = function (req, res, next) {
    res.json(req.project);
}
